//
//  WBTabBarViewController.m
//  OC版新浪微博
//
//  Created by chenguanglei on 16/11/27.
//  Copyright © 2016年 itheima. All rights reserved.
//

#import "WBTabBarViewController.h"
#import "WBTabBar.h"

@interface WBTabBarViewController ()

@end

@implementation WBTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];


//    self.view.backgroundColor = [UIColor yellowColor];
    
    [self setupUI];
    
}

- (void)setupUI{

    
    
    [self setValue:[WBTabBar new] forKey:@"tabBar"];
    
    
    [self.tabBar setTintColor:[UIColor orangeColor]];
    
    [self addChildController:@"WBHomeViewController" title:@"首页" imageName:@"tabbar_home"];
    [self addChildController:@"WBFindViewController" title:@"发现" imageName:@"tabbar_discover"];
    [self addChildController:@"WBMessageViewController" title:@"消息" imageName:@"tabbar_message_center"];
    [self addChildController:@"WBMineViewController" title:@"我的" imageName:@"tabbar_profile"];
    
    
  
    
}


- (void)addChildController:(NSString *)controllerName title:(NSString*)title imageName:(NSString *)imageName{

    Class cla = NSClassFromString(controllerName);
    
    UIViewController *findCV = [[cla alloc]init];
    
    findCV.title = title;
    
    [findCV.tabBarItem setImage:[UIImage imageNamed:imageName]];
    
    NSString *name = [NSString stringWithFormat:@"%@_highlighted",imageName];
    
    [findCV.tabBarItem setSelectedImage:[UIImage imageNamed:name]];
    
    NSDictionary *attr = @{NSForegroundColorAttributeName:[UIColor orangeColor],NSFontAttributeName:[UIFont systemFontOfSize:12]};
    
    [findCV.tabBarItem setTitleTextAttributes:attr forState:UIControlStateSelected];

    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:findCV];
    
    [self addChildViewController:nav];
}


@end
